package com.example.contact.repository

import com.example.contact.dao.ContactDao
import com.example.contact.model.Contact
import com.example.featuresdk.model.User
import com.example.featuresdk.repository.IRepository
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class ContactRepository @Inject constructor(private val contactDao: ContactDao): IRepository<Contact> {

    fun getAll(ownerId: Long): Flow<Map<Contact, User>> {
        return contactDao.getAll(ownerId)
    }

    suspend fun getOne(ownerId: Long, contactId: Long): Contact?{
        return contactDao.getOne(ownerId, contactId)
    }

    override suspend fun create(item: Contact) {
        contactDao.insert(item)
    }
}